define(function(require, exports, module) {

var $=require("jq.js");
// 用户登录模块


// 触发登录事件
var pointBtn = $('.go-btn');
var isUserLogin = $('#isUserLogin').val();

pointBtn.on("click",function(){
	if(isUserLogin == 0){
		innerLoginFrom();
	}else{
		var objId = $(this).attr('objid');
		window.location.href="/pointShop/exchange.do?objId="+objId;
	}
});

$('.fl .check').on('click',function(){
	if(isUserLogin == 0){
		innerLoginFrom();
	}else{
		var dataLink = $(this).attr('datalink');
		var class_on = $(this).attr('class');
		if(class_on.indexOf('on')<0){
			window.location.href=dataLink;
		}
	}
});

//写入登陆html
var innerLoginFrom = function(){
	var loginHtml = "<div class='J_PZLogin' ><div class='J_PZLogin_box' id='validate-login'><div class='J_PZLogin_caption'><span class='J_PZLogin_caption_text'>用户登录</span></div><div class='J_PZLogin_content'><span id='warning'><s></s><strong>请输入4位数验证码,看不清换一张试试！</strong></span><form data-tourl='/pointShop/list.do'><div class='J_PZLogin_form'><ul><li><div class='t'><label for='userName'>用户名</label></div><div class='d'><input class='' autocomplete='off' tabindex='1' autofocus='' type='text' id='userName' name='userName'></div></li><li><div class='t'><a href='/findPwd1.do' target='_blank'>忘记登录密码?</a><label for='userPassword'>登录密码</label></div><div class='d'><input type='password' tabindex='2' id='userPassword' name='password'></div></li><li><div class='t'><label for='validateCode'>验证码</label></div><div class='d sp'><input type='text' tabindex='3' autocomplete='off' id='validateCode' name='validateCode'></div><div class='validate-code-pic'><img src='/validateCode' alt='' height='23' width='67'><a href='javascript:void(0);'>看不清?换一张</a></div></li><li><span class='dis-login'><input type='checkbox' tabindex='4' id='oneWeek' name='disLogin' value='no'>一周内自动登录<strong>(不是常用电脑不要勾选)</strong></span></li><li><input class='submit-btn' type='button' value=' '></li><li><a href='/register.do' target='_blank' class='dis-regist'>免费注册</a></li></ul></div></form></div></div></div>"
	var mask = "<div class='J_PZLogin_mask'></div>"
	$("body").append(loginHtml +mask );
	var J_PZLogin = $(".J_PZLogin");
	var css = require('/pointShop/css/pz_login.css'); //引入css文件
	var loginCheck = require('login-validate.js'); //引入js校验
	$('.J_PZLogin_mask').css("height",$(window).height());
	center(J_PZLogin);
}


var center = function(dom){

	 var top = ($(window).height() - dom.height())/2;
         var left = ($(window).width() - dom.width())/2;
         var scrollTop = $(document).scrollTop();
         var scrollLeft = $(document).scrollLeft();
         if (top<0) {
          var top = 30;
         }
         return dom.css( { position : 'absolute', 'top' : top+scrollTop, left : left + scrollLeft } );
}

// var checkFunForm = function(){

// 	//保存用户名
// 	var userName = $("#userName").val();
// 	//密码
// 	var userPwd  = $("#userPwd").val();
// 	//验证码
// 	var checkStr = $("checkStr").val();


// 	subFormFun(userName,userPwd,checkStr);

// }

// var subFormFun = function(name,pwd,checkStr){

// 	console.log();


// }

});
